//////////////////////////////////////////////////////////////////////////////////////////////////////////// // // //-------------------------------- Ebrahim Foulaadvand, 13 Oct 2012 ----------------------------------- // // // // The routine "DiffusionFTCS" solves the heat transfer equation using forward time centered space // // scheme. Dirichlet boundary condition is used. // // // // //// // //////////////////////////////////////////////////////////////////////////////////////////////////////////// #include #include #include #include #include #include #include #include #include #include using namespace std; main() { double k=1,tau=0.01,h,L=1,TL=10,TR=30; // k=thermal conductivity, tau=time step, h=spatial grid. //L=system length, TL=temerature at the left boundary, TR=temerature at the right boundary. int N=60,i,n,Time=5000; // N=number of spatial grids, Time=number of timesteps, n=timestep number. vector Tcur(N+1,0),Tnew(N+1,0); // Arrays "Tcur" and "Tnew" store the current and updated temperature values at grid points. ofstream file1 ("Tepmerature n=10.plt"); //output file for temperature profile at timestep n=10. ofstream file2 ("Tepmerature n=100.plt"); //output file for temperature profile at timestep n=100. ofstream file3 ("Tepmerature n=1000.plt"); //output file for temperature profile at timestep n=1000. ofstream file4 ("Tepmerature n=5000.plt"); //output file for temperature profile at timestep n=5000. h=L/N; cout<<"h= "<